<?php
declare(strict_types=1);

namespace app\common\controller;

use Exception;
use think\facade\Session;

/**
 * | Notes：Api
 * +----------------------------------------------------------------------
 * | PHP Version 7.2+
 * +----------------------------------------------------------------------
 * | Copyright (c) 2011-2020 https://www.xxq.com.cn, All rights reserved.
 * +----------------------------------------------------------------------
 * | Author: 和好 <389123492@qq.com>
 * +----------------------------------------------------------------------
 * | Date: 2020/5/20 10:35
 * +----------------------------------------------------------------------
 */
class Index extends AppBase
{
    /**
     * initialize 初始化
     */
    public function initialize()
    {
        parent::initialize(); // TODO: Change the autogenerated stub
    }

    /**
     * 验证码错误
     *
     * @param string $mobile
     * @param string $verify_code
     *
     * @return bool
     */
    public static function checkVerifySms(string $mobile, string $verify_code = ''): bool
    {
        $smsauth = Session::get('sms_secret_key');
        // 验证验证码
        if (isset($smsauth['encryption']) && md5($mobile . $verify_code) === $smsauth['encryption']) return true;

        return false;
    }
}
